
module.exports = {
  noBuyIfMarketInfo () {
    if (!this.marketInfo) {
      return
    }
    if (this.ifCanIgnoreNobuy) {
      return
    }
    if (this.marketInfo && this.marketInfo.crash15m) {
    }
    if (this.marketFlagInfo.indexIfMarketUpTrend) {
      if (this.marketInfo.ema15mBad || this.marketInfo.macd15mBad) {
        if (!this.marketInfo.kdj15mGood && !this.marketFlagInfo.isMarketLittleGoodUp) {
          this.setNoBuy('noBuyIfMarketInfo-2-1')
        }
      }
    }
    if (
      (this.marketInfo.kdj15mGood && !this.marketFlagInfo.ifMarket15mMacdEmaHasGood) &&
      (!this.marketInfo.kdj1hGood && !this.marketInfo.macd1hGood && this.marketInfo.ema1hGood) &&
      !(this.marketFlagInfo.isMarketLittleGoodUp)
    ) {
      // 挺好的
      // 真正的牛股在其他时候就会发出买入信号
      this.setNoBuy('noBuyIfMarketInfo-3-1')
    }
    // if (this.marketFlagInfo.ifMarket15mAllGood) {
    //   // 真正的牛股在其他时候就会发出买入信号
    //   this.setNoBuy('noBuyIfMarketInfo-3-2')
    // }
    if (this.marketFlagInfo.ifMarket4hMacdEmaAllBad && this.marketFlagInfo.ifMarket1hHasBad && this.marketFlagInfo.ifMarket1dHasBad) {
      if (!(
        this.marketFlagInfo.ifMarket15mAllBad
      )) {
        if (this.strategy === '2') {
          this.setNoBuy('noBuyIfMarketInfo-3-3')
        }
      }
    }
  },
  noBuyIfStatusBad () {
    if (this.ifCanIgnoreNobuy) {
      return
    }
    if (this.marketFlagInfo.isMarketBigBadDown || this.marketFlagInfo.isMarketLittleBadDown) {
      this.setNoBuy('noBuyIfStatusBad-1')
    }
    if (this.marketFlagInfo.isMarketMiniBadDown) {
      if (this.strategy === '2') {
        this.setNoBuy('noBuyIfStatusBad-2')
      }
    }
    // macd第一个k容易发疯
    if (this.marketMachine.ifMarket1dModelLike([-1, [0, -1], [0, -1]])) {
      if (this.strategy === '2' && this.analysisInfo1d.macdDownDays === 1) {
        this.setNoBuy('noBuyIfStatusBad-3')
      }
    }
    if (
      this.marketMachine.ifMarket4hModelLike([-1, -1, [0, -1]]) &&
      this.marketMachine.ifMarket1dModelLike([[0, -1], [0, -1], [0, -1]])
    ) {
      if (this.strategy === '2' && this.analysisInfo4h.macdDownDays === 1) {
        this.setNoBuy('noBuyIfStatusBad-4')
      }
    }
    if (
      !this.analysisInfo1d.hasFullData &&
      this.analysisInfo4h.macd < 0 &&
      this.analysisInfo4h.ema5B10B20Days >= 1 &&
      (
        this.analysisInfo4h.kdjDiff < 0 ||
        this.analysisInfo4h.macdDownDays >= 8 ||
        this.analysisInfo4h.ema5B10B20Days >= 8
      ) &&
      this.analysisInfo1h.macd < 0 &&
      this.analysisInfo1h.ema5B10B20Days >= 1 &&
      (
        this.analysisInfo1h.kdjDiff < 0 ||
        this.analysisInfo1h.macdDownDays >= 8 ||
        this.analysisInfo1h.ema5B10B20Days >= 8
      )
    ) {
      if (this.strategy === '2') {
        this.setNoBuy('noBuyIfStatusBad-5')
      }
    }
  },
  noBuyIfNewLow () {
    // 新高的东西，不开逆向仓，你要是那么厉害，那就去reason卖出去
    if (
      this.indexFlagInfo.isIndexInNewLowTrend ||
      this.indexFlagInfo.isIndexCloseNowNewLow ||
      this.indexFlagInfo.isIndexCloseNewLow
    ) {
      if (!this.marketFlagInfo.ifMarket15mAllBad4Days) {
        this.setNoBuy('noBuyIfNewLow-1')
      }
    }
  },
  noBuyIfNoProfit () {
    if (
      this.symbolAccount.position > 0.3 && this.hasDuoPosition &&
      !(this.marketFlagInfo.ifMarket15mAllGood || this.marketFlagInfo.ifMarket15mAllBad)
    ) {
      if (this.symbolAccount.incomeRate <= 0.2) {
        this.setNoBuy('noBuyIfNoProfit-1')
      }
    }
    // 亏损超过本金一个点的东西不允许加仓
    if (this.symbolAccount.position > 0.3 && this.hasDuoPosition) {
      if (this.symbolAccount.incomeAssetRate <= -1) {
        this.setNoBuy('noBuyIfNoProfit-2')
      }
    }
  },
  noBuyIfLineBad () {
    if (this.strategy === '2') {
      return
    }
    if (this.ifCanIgnoreNobuy) {
      return
    }
    if (this.analysisInfo15m.macdUpDays >= 20 && this.analysisInfo15m.macdUpDays <= 96) {
      // const needleLineTime = this.analysisInfoFlag15m.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo15m.macdUpDays)
      // if (needleLineTime > (0.4 * this.analysisInfo15m.macdUpDays)) {
      //   if (this.strategy === '1') {
      //     this.setNoBuy('noBuyIfLineBad-1', {
      //       canReverse: true
      //     })
      //   }
      // }
      const downDays = this.analysisInfoFlag15m.getNetChangeRatioDownDaysInRange(this.analysisInfo15m.macdUpDays).days
      if (downDays > (0.5 * this.analysisInfo15m.macdUpDays)) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-2', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.macdUpKeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-3', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.macdUpKeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-3-1', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.macdUpKeepInfo.mdrr > 0.5) {
        this.setNoBuy('noBuyIfLineBad-3-3', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo15m.ema5W10A20Days >= 20 && this.analysisInfo15m.ema5W10A20Days <= 96) {
      // const needleLineTime = this.analysisInfoFlag15m.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo15m.ema5W10A20Days)
      // if (needleLineTime > (0.4 * this.analysisInfo15m.ema5W10A20Days)) {
      //   if (this.strategy === '1') {
      //     this.setNoBuy('noBuyIfLineBad-4', {
      //       canReverse: true
      //     })
      //   }
      // }
      const downDays = this.analysisInfoFlag15m.getNetChangeRatioDownDaysInRange(this.analysisInfo15m.ema5W10A20Days).days
      if (downDays > (0.5 * this.analysisInfo15m.ema5W10A20Days)) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-5', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.ema5W10A20KeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-6', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.ema5W10A20KeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-7', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.ema5W10A20KeepInfo.mdrr > 0.5) {
        this.setNoBuy('noBuyIfLineBad-7-1', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo15m.ema5W10A20Days >= 15) {
      if (this.analysisInfo15m.ema5W10A20KeepInfo.ftdmrr > 0.7) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-8', {
            canReverse: true
          })
        }
      }
    }
    if (!this.marketFlagInfo.isMarketBigGoodUp) {
      if (this.analysisInfo15m.netChangeRatio >= 7.5) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-9')
        }
      }
    }
    if (this.analysisInfo15m.kdjUpDays === 1) {
      if (this.analysisInfo15m.lastKdjDownDays === 1) {
        this.setNoBuy('noBuyIfLineBad-11', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo1h.macdUpDays >= 20) {
      // const needleLineTime = this.analysisInfoFlag1h.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo1h.macdUpDays)
      // if (needleLineTime > (0.4 * this.analysisInfo1h.macdUpDays)) {
      //   if (this.strategy === '1') {
      //     this.setNoBuy('noBuyIfLineBad-12', {
      //       canReverse: true
      //     })
      //   }
      // }
      const downDays = this.analysisInfoFlag1h.getNetChangeRatioDownDaysInRange(this.analysisInfo1h.macdUpDays).days
      if (downDays > (0.5 * this.analysisInfo1h.macdUpDays)) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-12-1', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.macdUpKeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-12-2', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.macdUpKeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-12-3', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.macdUpKeepInfo.mdrr > 0.5) {
        // 反向也能恶心死你
        this.setNoBuy('noBuyIfLineBad-12-4', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo1h.ema5W10A20Days >= 20) {
      // const needleLineTime = this.analysisInfoFlag1h.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo1h.ema5W10A20Days)
      // if (needleLineTime > (0.4 * this.analysisInfo1h.ema5W10A20Days)) {
      //   if (this.strategy === '1') {
      //     this.setNoBuy('noBuyIfLineBad-13', {
      //       canReverse: true
      //     })
      //   }
      // }
      const downDays = this.analysisInfoFlag1h.getNetChangeRatioDownDaysInRange(this.analysisInfo1h.ema5W10A20Days).days
      if (downDays > (0.5 * this.analysisInfo1h.ema5W10A20Days)) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-13-1', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.ema5W10A20KeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-13-2', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.ema5W10A20KeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-13-3', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.ema5W10A20KeepInfo.mdrr > 0.5) {
        // 反向也能恶心死你
        this.setNoBuy('noBuyIfLineBad-13-4', {
          canReverse: true
        })
      }
    }
    if (this.strategy === '2' && Math.abs(this.analysisInfo15m.emaMaxDiff) < 1) {
      this.setNoBuy('noBuyIfLineBad-14', {
        canReverse: true
      })
    }
    // 正向，你前几天是跌的就不弄了
    const upDaysIn4 = this.analysisInfoFlag15m.getNetChangeRatioUpDaysInRange(4).days
    if (
      (upDaysIn4 <= 1 && this.analysisInfo15m.netChangeRatio > 0)
    ) {
      if (this.strategy === '1' && this.buy) {
        // 你这几天是跌的肯定不能买
        this.setNoBuy('noBuyIfLineBad-15', {
          canReverse: true
        })
        this.setStrategy('2', 'nb-1-1')
        this.setSellRaw(`r-lineBadSell`, {
        })
      }
    }
    if (this.analysisInfo1h.ema5W10A20Days >= 70 && this.analysisInfo1h.ema5W10A20KeepInfo.highIndex > 6) {
      if (
        this.analysisInfo15m.macdUpDays >= 3 ||
        this.analysisInfo15m.kdjUpDays >= 3
      ) {
        if (this.strategy === '1') {
          this.setNoBuy('noBuyIfLineBad-15', {
            canReverse: true
          })
        }
      }
    }
    if (
      this.analysisInfo15m.kdjDiff < 0 &&
      this.analysisInfo15m.kdjDownKeepInfo.maxCloseRate >= 30
    ) {
      this.setNoBuy('noBuyIfLineBad-17')
    }
    if (this.symbolAccount.position > 0.3 && this.hasDuoPosition && this.btbItem.strategy === '2') {
      if (this.indexFlagInfo.isIndexCloseNewLow && !this.is4hChangeTime) {
        this.setNoBuy('noBuyIfLineBad-18')
      }
    }
  },
  neverBuyIfLineBad () {
    if (this.analysisInfoFlag1h.countLowNetChangeTimes(60) >= 30) {
      if (['BTC', 'ETH'].indexOf(this.btbItem.code) === -1) {
        this.setNoBuy('neverBuyIfLineBad-1')
      }
    }
    if (this.analysisInfoFlag4h.countLowNetChangeTimes(60) >= 30) {
      if (['BTC', 'ETH'].indexOf(this.btbItem.code) === -1) {
        this.setNoBuy('neverBuyIfLineBad-2')
      }
    }
    if (
      !this.analysisInfo1d.hasFullData &&
      this.btbItem.price_change_percent > 150
    ) {
      this.setNoBuy('neverBuyIfLineBad-4')
    }
  }
}
